package com.topvision.camerasdk.camera2;

import android.util.Size;

import java.util.Comparator;

/**
 * Created by gushenjie on 18/5/30.
 */

public class CompareSizesByArea implements Comparator<Size> {
    /**
     * Compares two {@code Size}s based on their areas.   为Size定义一个比较器Comparator
     */

        @Override
        public int compare(Size lhs, Size rhs) {
            // We cast here to ensure the multiplications won't overflow
            // 强转为long保证不会发生溢出
            return Long.signum((long) lhs.getWidth() * lhs.getHeight() -
                    (long) rhs.getWidth() * rhs.getHeight());
        }

}
